package me.muci.thread01_create;

import java.util.concurrent.*;

/**
 * ClassName: Test <br/>
 * Description: <br/>
 * date: 2021/8/6 11:13<br/>
 *
 * @author muci<br />
 * @description
 * @since JDK 1.8
 */
public class Test {

    @org.junit.Test
    public void test() throws ExecutionException, InterruptedException {
        CreateThreadByThread threadByThread = new CreateThreadByThread();
        threadByThread.start();
        CreateThreadByRunnable threadByRunnable = new CreateThreadByRunnable();
        Thread thread1 = new Thread(threadByRunnable);
        thread1.start();

        CreateThreadByCallable threadByCallable = new CreateThreadByCallable();
        FutureTask<String> futureTask = new FutureTask<>(threadByCallable);
        Thread thread2 = new Thread(futureTask);
        thread2.start();
        System.out.println(futureTask.get());

    }

    @org.junit.Test
    public void test1() throws InterruptedException {
        ExecutorService executorService = new ThreadPoolExecutor(1,1,60L,TimeUnit.SECONDS,new ArrayBlockingQueue<Runnable>(10));
        executorService.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName());
            }
        });
    }
}
